//
//  HZ_CollectionReusableView.m
//  HZ_Beautiful_Music
//
//  Created by dllo on 16/3/31.
//  Copyright © 2016年 ui. All rights reserved.
//

#import "HZ_CollectionReusableView.h"

@implementation HZ_CollectionReusableView

- (void)dealloc {
    
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        NSString *state = [[NSUserDefaults standardUserDefaults] objectForKey:@"night"];
        if ([state isEqualToString:@"yes"]) {
            self.backgroundColor = [UIColor colorWithRed:49 / 255.0 green:47 / 255.0 blue:53 / 255.0 alpha:1];
        }else {
            self.backgroundColor = [UIColor clearColor];
        }
    }
    NSNotificationCenter *centerTWO = [NSNotificationCenter defaultCenter];
    
    [centerTWO addObserver:self selector:@selector(buttonNotification:) name:@"heibai" object:nil];
    
    return  self;
    
}

- (void)buttonNotification:(NSNotification *)notification{
    UIColor *color = [notification object];
    self.backgroundColor = color;
    if (color == [UIColor clearColor]) {
        self.backgroundColor = [UIColor clearColor];
    }else {
        self.backgroundColor = [UIColor colorWithRed:49 / 255.0 green:47 / 255.0 blue:53 / 255.0 alpha:1];
    }
    
}


@end
